home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '87 / Source ƒ.sea / Source ƒ / emacs source ƒ / TIPC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-28  |  5.2 KB  |  196 lines  |  [TEXT/MARC]

  1. /*
  2.  * The routines in this file provide support for the TI-PC and other
  3.  * compatible terminals. It goes directly to the graphics RAM to do
  4.  * screen output. It compiles into nothing if not a TI-PC driver
  5.  */
  6.  
  7. #define termdef 1                       /* don't define "term" external */
  8.  
  9. #include        <stdio.h>
  10. #include        "estruct.h"
  11. #include        "edef.h"
  12.  
  13. #if     TIPC
  14.  
  15. #define NROW    25                      /* Screen size.                 */
  16. #define NCOL    80                      /* Edit if you want to.         */
  17. #define MARGIN  8                       /* size of minimim margin and   */
  18. #define SCRSIZ  64                      /* scroll size for extended lines */
  19. #define NPAUSE  200                     /* # times thru update to pause */
  20. #define BEL     0x07                    /* BEL character.               */
  21. #define ESC     0x1B                    /* ESC character.               */
  22. #define SPACE   32                      /* space character              */
  23. #define SCADD   0xDE000L                /* address of screen RAM        */
  24.  
  25. #define CHAR_ENABLE     0x08            /* TI attribute to show char    */
  26. #define TI_REVERSE      0x10            /* TI attribute to reverse char */
  27. #define BLACK   0+CHAR_ENABLE           /* TI attribute for Black       */
  28. #define BLUE    1+CHAR_ENABLE           /* TI attribute for Blue        */
  29. #define RED     2+CHAR_ENABLE           /* TI attribute for Red         */
  30. #define MAGENTA 3+CHAR_ENABLE           /* TI attribute for Magenta     */
  31. #define GREEN   4+CHAR_ENABLE           /* TI attribute for Green       */
  32. #define CYAN    5+CHAR_ENABLE           /* TI attribute for Cyan        */
  33. #define YELLOW  6+CHAR_ENABLE           /* TI attribute for Yellow      */
  34. #define WHITE   7+CHAR_ENABLE           /* TI attribute for White       */
  35.  
  36.  
  37. extern  int     ttopen();               /* Forward references.          */
  38. extern  int     ttgetc();
  39. extern  int     ttputc();
  40. extern  int     ttflush();
  41. extern  int     ttclose();
  42. extern  int     timove();
  43. extern  int     tieeol();
  44. extern  int     tieeop();
  45. extern  int     tibeep();
  46. extern  int     tiopen();
  47. extern  int     tirev();
  48. extern  int     ticlose();
  49. extern  int     tiputc();
  50.  
  51. #if     COLOR
  52. extern  int     tifcol();
  53. extern  int     tibcol();
  54.  
  55. int     cfcolor = -1;           /* current forground color */
  56. int     cbcolor = -1;           /* current background color */
  57. int     ctrans[] =              /* ansi to ti color translation table */
  58.         {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
  59. #endif
  60.  
  61. /*
  62.  * Standard terminal interface dispatch table. Most of the fields point into
  63.  * "termio" code.
  64.  */
  65. TERM    term    = {
  66.         NROW-1,
  67.         NCOL,
  68.         MARGIN,
  69.         SCRSIZ,
  70.         NPAUSE,
  71.         tiopen,
  72.         ticlose,
  73.         ttgetc,
  74.         tiputc,
  75.         ttflush,
  76.         timove,
  77.         tieeol,
  78.         tieeop,
  79.         tibeep,
  80.         tirev
  81. #if     COLOR
  82.         , tifcol,
  83.         tibcol
  84. #endif
  85. };
  86.  
  87. extern union REGS rg;
  88.  
  89. #if     COLOR
  90. setatt( attr )
  91. int attr;
  92. {
  93.         rg.h.ah = 0x16;         /* set the forground character attribute */
  94.         rg.h.bl = attr;
  95.         int86( 0x49, &rg, &rg );
  96. }
  97.  
  98. tifcol(color)           /* set the current output color */
  99.  
  100. int color;      /* color to set */
  101.  
  102. {
  103.         cfcolor = ctrans[color];
  104.         setatt ( cfcolor );
  105. }
  106.  
  107. tibcol(color)           /* set the current background color */
  108.  
  109. int color;      /* color to set */
  110.  
  111. {
  112.         cbcolor = ctrans[color];
  113. }
  114. #endif
  115.  
  116. timove(row, col)
  117. {
  118.         rg.h.ah = 2;            /* set cursor position function code */
  119.         rg.h.dh = col;
  120.         rg.h.dl = row;
  121.         int86(0x49, &rg, &rg);
  122. }
  123.  
  124. tieeol()        /* erase to the end of the line */
  125.  
  126. {
  127.         int ccol;       /* current column cursor lives */
  128.         int crow;       /*         row  */
  129.  
  130.         /* find the current cursor position */
  131.         rg.h.ah = 3;            /* read cursor position function code */
  132.         int86(0x49, &rg, &rg);
  133.         ccol = rg.h.dh;         /* record current column */
  134.         crow = rg.h.dl;         /* and row */
  135.  
  136.         rg.h.ah = 0x09;         /* Write character at cursor position */
  137.         rg.h.al = ' ';          /* Space */
  138.         rg.h.bl = cfcolor;
  139.         rg.x.cx = NCOL-ccol;    /* Number of characters to write */
  140.         int86(0x49, &rg, &rg);
  141.  
  142. }
  143.  
  144. tiputc(ch)      /* put a character at the current position in the
  145.                    current colors */
  146.  
  147. int ch;
  148.  
  149. {
  150.         rg.h.ah = 0x0E;         /* write char to screen with current attrs */
  151.         rg.h.al = ch;
  152.         int86(0x49, &rg, &rg);
  153. }
  154.  
  155. tieeop()                        /* Actually a clear screen */
  156. {
  157.  
  158.         rg.h.ah = 0x13;         /* Clear Text Screen and Home Cursor */
  159.         int86(0x49, &rg, &rg);
  160. }
  161.  
  162. tirev(state)            /* change reverse video state */
  163.  
  164. int state;      /* TRUE = reverse, FALSE = normal */
  165.  
  166. {
  167.         setatt( state ? cbcolor : cfcolor  );
  168. }
  169.  
  170. tibeep()
  171. {
  172.         bdos(6, BEL, 0);
  173. }
  174.  
  175. tiopen()
  176. {
  177.         revexist = TRUE;
  178.         ttopen();
  179. }
  180.  
  181. ticlose()
  182.  
  183. {
  184. #if     COLOR
  185.         tifcol(7);
  186.         tibcol(0);
  187. #endif
  188.         ttclose();
  189. }
  190. #else
  191. tihello()
  192. {
  193. }
  194. #endif
  195.  
  196.